package com.atguigu.tingshu.order.interceptor.impl;

import com.alibaba.fastjson.JSON;
import com.atguigu.tingshu.order.context.SaveOrderStrategyContext;
import com.atguigu.tingshu.order.interceptor.OrderHandlerInterceptor;
import com.atguigu.tingshu.order.strategy.SaveOrderStrategy;
import com.atguigu.tingshu.vo.order.OrderInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class SavaOrderOrderHandlerInterceptor implements OrderHandlerInterceptor {
    @Override
    public OrderInfoVo sbumitOrderRequestProcess(OrderInfoVo orderInfoVo) {
        SaveOrderStrategy saveOrderStrategy = SaveOrderStrategyContext.getSaveOrderStrategy(orderInfoVo.getPayWay());
        log.info("{}保存订单数据", JSON.toJSON(saveOrderStrategy));
        return saveOrderStrategy.saveOrder(orderInfoVo);
    }

    @Override
    public int sort() {
        return 3;
    }
}
